package cn.gailvlun.gll.chatlib.dialog;

import android.support.annotation.NonNull;

import cn.gailvlun.gll.chatlib.message.Message;
import cn.gailvlun.gll.net.apartment.room.Room;
import cn.gailvlun.gll.net.base.Profile;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;



public class Dialog extends RealmObject {
    @PrimaryKey
    private String id; 
    private Profile profile;
    private Room room;
    private Message message;
    private long unreadCount;
    private String draft;

    public boolean isRoom() {
        if (id.split(":")[0].equals("user")) {
            return false;
        }
        return true;
    }

    public Integer getUserOrRoomId() {
        return Integer.valueOf(id.split(":")[1]);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Profile getProfile() {
        return profile;
    }

    public void setProfile(@NonNull Profile profile) {
        this.id = "user:" + profile.getId();
        this.profile = profile;
    }

    public Room getRoom() {
        return room;
    }

    public void setRoom(@NonNull Room room) {
        this.id = "room:" + room.getId();
        this.room = room;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public long getUnreadCount() {
        return unreadCount;
    }

    public void setUnreadCount(long unreadCount) {
        this.unreadCount = unreadCount;
    }

    public String getDraft() {
        return draft;
    }

    public void setDraft(String draft) {
        this.draft = draft;
    }
}
